export default {
	ws: {},
	createWs: function(n) {
		this.ws = n;
	},
	msguserlist: [],
	createMsgUserList: function(o) {
		this.msguserlist = o;
	},
	msglist: [],
	createMsgList: function(o) {
		this.msglist = o;
	},
	delCount: function(id) {
		this.msguserlist.forEach((item, index) => {
			if (item.uid == id) {
				item.unreadCount = 0;
			}
		})
		// 重新保存
		uni.setStorageSync("msgUserList", JSON.stringify(this.msguserlist));
	},
	addMsg: function(id, str) {
		this.msguserlist.forEach((item, index) => {
			if (item.uid == id) {
				item.lastCont = str;
			}
		})
		// 重新保存
		uni.setStorageSync("msgUserList", JSON.stringify(this.msguserlist));
	},
	addCount: function(id) {
		this.msguserlist.forEach((item, index) => {
			if (item.uid == id) {
				item.unreadCount = item.unreadCount + 1;
			}
		})
		// 重新保存
		uni.setStorageSync("msgUserList", JSON.stringify(this.msguserlist));
	},
	countSum: function() {
		let _sum = 0;
		this.msguserlist.forEach((item, index) => {
			_sum += item.unreadCount;
		})
		return _sum;
	}
}
